package com.sj.parksdk.net.request;

import com.sj.parksdk.net.base.CommonResult;
import com.sj.parksdk.net.manager.TokenManager;
import com.xuexiang.xhttp2.callback.CallBack;
import com.xuexiang.xhttp2.callback.CallBackProxy;
import com.xuexiang.xhttp2.callback.CallClazzProxy;
import com.xuexiang.xhttp2.request.PostRequest;

import java.lang.reflect.Type;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;

public class MPostRequest extends PostRequest {
    public MPostRequest(String url) {
        super(url);
    }

    @Override
    public <T> Observable<T> execute(Type type) {
        return execute(new CallClazzProxy<CommonResult<T>, T>(type) {
        });
    }

    @Override
    public <T> Disposable execute(CallBack<T> callBack) {
        return execute(new CallBackProxy<CommonResult<T>, T>(callBack) {
        });
    }

    public MPostRequest visit(){
        headers("Authorization", TokenManager.getInstance().getSign()+" "+TokenManager.getInstance().getVisitToken());
        return this;
    }

    public MPostRequest user(){
        headers("Authorization", TokenManager.getInstance().getSign()+" "+TokenManager.getInstance().getToken());
        return this;
    }
}
